package com.code.p9.工厂方法模式.P1简单工厂方法模式;

/**
 * 描述: 3 创建一个简单工厂
 *
 * @author CodeYang_Site
 * @version 2021/6/6 13:47
 */
public class ShapeFactory {

    /**
     * 根据工厂标识获取工厂实例
     * 接口 与 实现类
     *
     * @param shapeName
     * @return
     */
    public Shape getShape(String shapeName) {
        if (shapeName == null) {
            return null;
        }
        if (shapeName.equalsIgnoreCase("CIRCLE")) {
            return new CircleShapeImpl();
        }
        if (shapeName.equalsIgnoreCase("RECTANGLE")) {
            return new RectangleShapeImpl();
        }
        if (shapeName.equalsIgnoreCase("SQUARE")) {
            return new SquareShapeImpl();
        }

        return null;

    }
}
